# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: zml <zach at zachsthings dot com>
# Contributor: Ambroz Bizjak <ambrop7 at gmail dot com>

pkgname=badvpn
pkgver=1.999.130
pkgrel=7
pkgdesc="Peer-to-peer VPN system, and NCD, a programming language for network interface configuration"
arch=('loong64' 'x86_64')
url="https://github.com/ambrop72/badvpn"
license=('GPL')
depends=('nss' 'openssl' 'iproute2')
makedepends=('cmake')
source=("$pkgname-$pkgver.tar.gz::https://github.com/ambrop72/badvpn/archive/$pkgver.tar.gz"
        'badvpn-udpgw.service'
        'badvpn-ncd.service'
        'badvpn-ncd.conf.d')
md5sums=('e65d8d298fc82eb9a6c12a9425a97e6d'
         'c2880cc0dff000d12e65bcd38fc9f02c'
         '35cf690b7cdf90fdb7abf9edcd5e4540'
         '19ea2de11e1623c5e91a363e72c329f1')
sha256sums=('bfd4bbfebd7274bcec792558c9a2fd60e39cd92e04673825ade5d04154766109'
            '68c13de80e6bbb640cf836830fdc1e3db64d7b63ffd9c2fc35ce91fc8598415b'
            '9a62373f5c01f53876e39dbea7d9a5334968733ec0b806748145b6db045141cd'
            '8596498d37454a137d2a3a5878e047d2f07bfa232f30ebb8e83b7d2f28f22a8b')

build() {
  cd $pkgname-$pkgver
  cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release .
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install

  install -Dm644 "$srcdir"/badvpn-udpgw.service "$pkgdir"/usr/lib/systemd/system/badvpn-udpgw.service
  install -Dm644 "$srcdir"/badvpn-ncd.service "$pkgdir"/usr/lib/systemd/system/badvpn-ncd.service
  install -Dm644 "$srcdir"/badvpn-ncd.conf.d "$pkgdir"/etc/conf.d/badvpn-ncd
}
